Skip to content

csnode: BlockVerifier for blocks that come from outside the consensus - #90

Merged
EnzinoBB merged 5 commits into
masterfrom
feat/block-verifier
Oct 24, 2026
Merged

EnzinoBB merged 5 commits into
masterfrom
feat/block-verifier

Conversation

@EnzinoBB

Copy link
Copy Markdown
Collaborator

Step 3b of snapshots served by community nodes, shared with backward sync.

  • BlockVerifier::verify(block, expectedSequence, expectedHash): the block parses, has the expected sequence and, when given, the expected hash, computed from its bytes. For sequence ≥ 1 its signatures also verify against its own confidants with the real trusted mask, exactly as tryFlushDeferredBlock does. Block 0 needs none.
  • verifySignatures: the signatures alone. They are outside the hashed part, so they are the only thing a sender could alter without changing the hash.
  • verifyConfirmations(block, previousConfidants): the round confirmations, with finalizeBlock's exceptions (bootstrap blocks, one-entry masks).

Nothing uses it yet. Not consensus-relevant: the existing checks are unchanged and called the same way.

Tests use blocks signed with real keys: valid; wrong sequence; wrong hash; signatures by keys other than the confidants; fewer signatures than the mask; genesis; confirmations against the right and the wrong confidants.

🤖 Generated with Claude Code

EnzinoBB and others added 5 commits October 24, 2026 11:45
One verifier for the snapshot importer and backward sync: the block
parses, has the expected sequence and hash, and its signatures verify
against its own confidants with the real trusted mask, as the node does
when it stores a deferred block (block 0 has none). Round confirmations
are checked separately against the previous block's confidants, with
finalizeBlock's exceptions.

Step 3b of snapshots served by community nodes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An invalid pool reads as sequence 0 and was taken for the genesis block by
verifySignatures, which needs no signature there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Signature and confirmation counts are checked with a reason before
  checkGroupSignature, which logs them as errors (untrusted input).
- verifyConfirmations refuses a normal round's block without round
  confirmations, as storeBlock does.
- The header says an empty expectedHash proves only self-consistency:
  the caller must anchor the block.
- Tests: a flipped bit in a real pool signature (it parses, keeps its
  hash and fails), more signatures than the mask, no confidants, a block
  without confirmations, confirmations against a set of another size.
  The two former cases passed without reaching the check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@EnzinoBB
EnzinoBB merged commit 51ebd44 into master Oct 24, 2026
2 checks passed
EnzinoBB added a commit that referenced this pull request Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant